package org.xx.armory.config;

import org.xx.armory.config.app.AppSection;
import org.xx.armory.config.data.DataSection;
import org.xx.armory.config.log4j2.Log4j2Section;
import org.xx.armory.config.security.SecuritySection;
import org.xx.armory.config.service.ServiceSection;

import static org.xx.armory.commons.Validators.notNull;

/**
 * armory 的核心配置类，该类型的实例包含了所有的可配置项实例。
 */
public final class Configuration {
    private AppSection app;
    private SecuritySection security;
    private DataSection data;
    private ServiceSection service;
    private Log4j2Section log4j2;

    public Configuration() {
        this.app = new AppSection();
        this.security = new SecuritySection();
        this.data = new DataSection();
        this.service = new ServiceSection();
        this.log4j2 = new Log4j2Section();
    }

    public AppSection getApp() {
        return app;
    }

    public void setApp(AppSection app) {
        this.app = notNull(app, "app");
    }

    /**
     * 获取数据配置节。
     *
     * @return 数据配置节。
     */
    public DataSection getData() {
        return data;
    }

    public void setData(DataSection data) {
        this.data = notNull(data, "data");
    }

    public SecuritySection getSecurity() {
        return security;
    }

    public void setSecurity(SecuritySection security) {
        this.security = notNull(security, "security");
    }

    public Log4j2Section getLog4j2() {
        return log4j2;
    }

    public void setLog4j2(Log4j2Section log4j2) {
        this.log4j2 = notNull(log4j2, "log4j2");
    }

    public ServiceSection getService() {
        return service;
    }

    public void setService(ServiceSection service) {
        this.service = notNull(service, "service");
    }
}
